import React, {FC, useMemo} from "react";
import "../css/IframeContent.less";
import {configChange} from "../../Config.tsx";
import {addUrlParams} from "../../utils";
import {getItem} from "../../services/LocalDataService.tsx";

interface TabsContentProps {
    url: string,
    menuId?: string
    key?: string
}

let localToken: string;

configChange((Config: any) => {
    localToken = Config.localToken;
});

const IframeContent: FC<TabsContentProps> = (props) => {

    const renderTabsContent = useMemo(() => {
        return (<div className={"sf_core_main_layout_content_tabs_main_content"}>
            <iframe
                src={addUrlParams(props.url, {accessToken: getItem(localToken), key: props.key})}
                style={{width: '100%', height: '100%', minHeight: '600px'}}
                frameborder="0"
                allow="microphone">
            </iframe>
        </div>)
    }, [props.url, props.key]);
    return (renderTabsContent);
};

export default IframeContent;